package com.thinkfit.jy.activity;

import android.view.View;

import androidx.annotation.NonNull;

import com.common.lib.constant.EventBusEvent;
import com.common.lib.manager.DataManager;
import com.common.lib.view.OnInputListener;
import com.common.lib.view.VerifyCodeView;
import com.thinkfit.jy.R;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.HashMap;

public class MangeModeActivity extends MainActivity {

    private String PASSWORD = "1234";

    @Override
    protected int getLayoutId() {
        return R.layout.activity_mange_mode;
    }

    public void init() {
        VerifyCodeView verifyCodeView = findViewById(R.id.verifyCodeView);
        if (DataManager.Companion.getInstance().getMainStyle() == 3) {
            setBackground(R.id.rootView, R.drawable.app_bg_xm);
            setBackground(R.id.llInfo, R.drawable.shape_33ffffff_20);
            verifyCodeView.resetStyle();
        }
        resetDate();

        verifyCodeView.setOnInputListener(new OnInputListener() {
            @Override
            public void onSuccess(@NonNull String code) {
                if (!code.equals(PASSWORD)) {
                    showToast(R.string.app_error_psw);
                    verifyCodeView.clearCode();
                    return;
                }
                openActivity(SwitchMainStyleActivity.class);
                finish();
            }

            @Override
            public void onInput() {

            }
        });
    }


    @Override
    public void onClick(View v) {
    }


    protected void showBottomUI() {

    }

    @Override
    public boolean isMainActivity() {
        return false;
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onReceive(HashMap<String, Object> map) {
        if (map == null) {
            return;
        }
        if (map.containsKey(EventBusEvent.TIME_CHANGE)) {
            resetDate();
        } else {
            super.onReceive(map);
        }
    }
}